<?php
if(!empty($_POST["action"]))
{
	$_POST['rank']=empty($_POST['rank'])?0:$_POST['rank'];
	$_POST['tj']=empty($_POST['tj'])?0:$_POST['tj'];
	$_POST['stime']=strtotime($_POST['stime']);
	$_POST['etime']=strtotime($_POST['etime']);
	$_POST['identity']*=1;
	$_POST['shop_statu']*=1;

	$sql="update ".USER." set ifpay='$_POST[ifpay]',tj='$_POST[tj]',stime='$_POST[stime]',etime='$_POST[etime]',rank='$_POST[rank]',identity='$_POST[identity]',template='$_POST[template]',shop_statu='$_POST[shop_statu]'
		where userid='$_GET[userid]'";
	$re=$db->query($sql);
	if($re)
	{
		$sql="update ".PRO." set ifpay='$_POST[ifpay]' where userid='$_GET[userid]'";
		$db->query($sql);
		$sql="update ".INFO." set ifpay='$_POST[ifpay]' where userid='$_GET[userid]'";
		$db->query($sql);
		unset($_GET['id']);unset($_GET['s']);
		$getstr=implode('&',convert($_GET));
		msg("module.php?s=company.php&$getstr");
	}
}
//=====================================================
$sql="select * from ".USER." where userid='$_GET[userid]'";
$db->query($sql);
$de=$db->fetchRow();

$ifpay=$de['ifpay'];
$tj=$de['tj'];
$rank =$de['rank'];
$uptime=$de['uptime'];
$identity=$de['identity'];

if($re['stime'])
	$stime=date("Y-m-d",$de['stime']);
else
	$stime=date("Y-m-d");
if($re['etime'])
	$etime=date("Y-m-d",$de['etime']);
else
	$etime=(date("Y")+1).'-'.date("m-d");
	
@include_once('config/module_company_config.php');
$companyType=explode('|',$module_company_config['companyType']);
$identity=explode('|',$module_company_config['identity']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="main.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../script/Calendar.js"></script>
</head>
<body>
<div class="guidebox"><?php echo lang_show('system_setting_home');?> &raquo; <?php echo lang_show('mem_modify_info');?></div>
<div class="bigbox">
	<div class="bigboxhead"><?php echo lang_show('mem_modify_info');?></div>
	<div class="bigboxbody">
      <form method="post" action=""  name=cityform enctype="multipart/form-data">
        <table width='98%' border='0' cellspacing='0' cellpadding='0' align="center" class="menu">
		<?php if($module_company_config['identity']){?>
          <tr>
            <td height="24" align="left"><?php echo lang_show('member_level');?></td>
            <td>
			<select class="select" name="identity">
			<?php
			foreach($identity as $key=>$v)
			{
			?>
			<option value="<?php echo $key?>" <?php if($identity==$identity) echo "selected"; ?>><?php echo $v?></option>
			<?php
			}
			?>
		  </select>			</td>
          </tr>
		  <?php } ?>
          <tr> 
			<td width='15%' height="24" align="left">会员等级</td>
			<td width='92%'>
			  <select class="select" name="ifpay">
					<?php
						 $sql="select * from ".USERGROUP." order by group_id asc";
						$db->query($sql);
						$re=$db->getRows();
						foreach($re as $v)
						{
					?>
					<option value="<?php echo $v['group_id'];?>"
					<?php if ($v['group_id']==$ifpay) echo " selected";?>><?php echo $v['name'];?></option>
					<?php
					}
					?>
			  </select>			  </td>
          </tr>
		  <tr>
            <td height="24" align="left"><?php echo lang_show('vloid_time');?></td>
		    <td>
			<script language="javascript">
			var cdr = new Calendar("cdr");
			document.write(cdr);
			cdr.showMoreDay = true;
			</script>
			  <input type="text" name="stime" value="<?php echo $stime?>" onFocus="cdr.show(this);" class="ltext">
		      --
		      <input type="text" name="etime" value="<?php echo $etime?>" onFocus="cdr.show(this);" class="rtext">
		      (exp:2008-02-01) </td>
	      </tr>
          <tr>
            <td height="24" align="left"><?php echo lang_show('rank');?></td>
            <td><input class="text" name="rank" type="text" id="rank" value="<?php echo $rank?>"></td>
          </tr>
		  <tr> 
			<td width='15%' height="24" align="left"> 
			  <?php echo lang_show('recommend');?></td>
			<td width='92%'>
			<?php
			$rc_member = array(
				'0'=>lang_show('norec'),
				'1'=>lang_show('reccom'),
				'2'=>lang_show('startcom'),
			)
			?>
			  <select class="select" name="tj">
				  <?php foreach($rc_member as $key=>$v) {?>
					<option value="<?php echo $key; ?>" <?php if($tj==$key)echo "selected"; ?>><?php echo $v;?></option>
				  <?php } ?>
			   </select>
			</td>
          </tr>
		  <tr>
            <td height="24">是否开通商铺</td>
            <td>
			<input name="shop_statu" <?php if($de['shop_statu']==1){?>checked="checked"<?php } ?> type="radio" value="1" />开启
			<input name="shop_statu" <?php if($de['shop_statu']==2){?>checked="checked"<?php } ?> type="radio" value="2" />
关闭
			</td>
          </tr>
          <tr>
            <td height="24">商铺模板</td>
            <td><input name="template" value="<?php echo $de['template'];?>" class="text" type="text" /></td>
          </tr>
          <tr> 
			<td width='15%' height="24">&nbsp;</td>
			<td width='92%'> 
			  <input class="btn" style="width:50px;" type='submit' name='submit' value='<?php echo lang_show('submit');?>'>
			  <input name="action" type="hidden" id="action" value="submit">			  </td>
          </tr>
        </table>
      </form>
	</div>
</div>
</body>
</html>